<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" type="text/css" href="../../css/style.css" />
<link rel="stylesheet" type="text/css" href="../../css/demo.css" />
<script src="../../js/demo.js" type="text/javascript" charset="utf-8"></script>
<title>批量管理</title>
</head>
<body>
	<!--header-->
	<div class="header">
		<div class="header-content">
			<ul class="nav left">
				<li><img src="../../img/regist-arrow.png" /></li>
				<li class="nav-one"><a href="javascript:history.go(-1);">返回</a></li>
				<li class="nav-two"><a href="../../">关闭</a></li>
			</ul>
			<p class="left">批量管理</p>
			<div class="right nav_right">
				<img src="../../img/regist-list.png" />
			</div>
		</div>
	</div>
	<!--main-->
	<div class="main clear">
		<div class="shopaccount-pro">
			<div class="left"
				style="position: absolute; top: 0.42rem; left: 50%; margin-left: -3rem;">
				<img src="../../img/shopuser-icon4.png"
					style="width: 0.16rem; height: 0.29rem;" />
			</div>
			<ul class="shopaccount-prolist">
				<li>
				<select onchange="getStatus2()" style="height: 50px;background-color: #EFEFF0;border: none;font-size: 25px;"
				>
					<option id="o1" selected="selected" value="1">销售中</option>
					<option id="o2" value="2">待售</option>
				</select>
				<li>
				<select onchange="selectGoodByOrder()" style="height: 50px;background-color: #EFEFF0;border: none;font-size: 25px">
					<option value="1">最新排序</option>
					<option value="2">按销量排序</option>
					<option value="3">按佣金排序</option>
					<option value="4">按售价排序</option>
					<option value="5">按收藏排序</option>
				</select>
					
				</li>
				<li>筛选<img src="../../img/shopmanagement-icon3.png" alt="" /></li>
			</ul>
			<img src="../../img/shopmanage-line.png" class="shopaccount-line" /> <img
				src="../../img/shopmanage-line.png" class="shopaccount-line2" />
			<div class="shopmanage-line3">
				<img src="../../img/shopmanage-line2.png" />
			</div>
			<div class="shopaccount-checkox" id="d1"></div>

			<div class="shopmanage-line3">
				<img src="../../img/shopmanage-line2.png" />
			</div>
			<div class="shopaccount-checkox" id="d2">
				
			</div>
			<div class="shopmanage-line3">
				<img src="../../img/shopmanage-line2.png" />
			</div>
			<div class="shopaccount-checkox" id="d3">
			
			</div>
			<div class="shopmanage-line3">
				<img src="../../img/shopmanage-line2.png" />
			</div>
			<div class="shopaccount-checkox" id="d4">
			</div>
			<div class="shopmanage-line3">
				<img src="../../img/shopmanage-line2.png" />
			</div>
			<div class="shopaccount-checkox" id="d5">
			</div>
		</div>
	</div>
	<div class="shopaccount-foot">
		<ul class="shopaccount-footlist">
			<li class="shop-footlist-one"><img
				src="../../img/shopaccount-icon2.png" id="i6" />全选</li>
			<li class="shop-footlist-two">删除</li>
			<li class="shop-footlist-thr">上架</li>
			<li class="shop-footlist-fou">下架</li>
		</ul>
	</div>
	<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
	<script type="text/javascript">
	
	manageGood();
		function manageGood() {
			$
					.ajax({
						type : "post",
						url : "/qiaomengapp/shopGood/manageGood",
						dataType : "json",
						success : function(data) {
							for (var i = 0; i <= data.length; i++) {
								$(eval("d" + (i + 1)))
										.html(
												"<img src='../../img/shopaccount-icon2.png' onclick='checkedGood()'"+ 
												"shopGoodId='"+ data[i].id+ "'/>"
														+ "<div class='shopaccount-list left'>"
														+ "<img src='"+data[i].goodImgurl+"' />"
														+ "<ul class='shopaccount-listes left'>"
														+ "<li class='shopaccount-one'>"
														+ data[i].goodDesc
														+ "</li>"
														+ "<li class='shopaccount-two'>"
														+ "￥"
														+ data[i].price
														+ "&nbsp;<span>佣金:</span><span>￥"
														+ data[i].commission
														+ "</span></li>"
														+ "<li class='shopaccount-thr'>剩余<span>"
														+ data[i].sum
														+ "</span>"
														+ "<span style='margin-right: 0.05rem;'>件</span> 销量"
														+ "<span style='margin-right: 0.1rem;'>"
														+ data[i].salesCount
														+ "</span> 收藏<span>"
														+ data[i].focusNum
														+ "</span></li>"
														+ "</ul></div>")
							}
						}
					});
		}
		//给全选按钮绑定click事件
		$('img[src="../../img/shopaccount-icon2.png"]').click(checkedGood);
		//按钮选择
		function checkedGood() {
			var a = event.target;
			var c = $('#i6')[0];
			var b = $(a).attr('src');
			if (b == "../../img/shopaccount-icon2.png") {
				if (c == a) {
					$('img[src="../../img/shopaccount-icon2.png"]').attr('src',
							'../../img/shopaccount-icon.png');
				} else {
					$(a).attr('src', '../../img/shopaccount-icon.png');
				}
			} else {
				if (c == a) {
					$('img[src="../../img/shopaccount-icon.png"]').attr('src',
							'../../img/shopaccount-icon2.png');
				} else {
					$(a).attr('src', '../../img/shopaccount-icon2.png');
				}
			}
		};
		function getShopId() {
			//获取所有图片为选中状态的  jq对象===>list,为一个数组
			var array = $('img[src="../../img/shopaccount-icon.png"]');
			var dataStr = "1=1";
			var c = $('#i6')[0];
			for (var i = 0; i < array.length; i++) {
				//取出array中的每个对象===>变成js对象，使用getAttribute方法来获取属性值
				//多个shopGoodId的传递
				if(array[i]!=c){
				dataStr += "&shopGoodId=" + array[i].getAttribute('shopGoodId');
				}
			}
			return dataStr;
		}
		//删除
		$('li[class="shop-footlist-two"]').click(

				function() {
					var dataStr = getShopId();
					$.ajax({
						type : "post",
						url : "/qiaomengapp/shopGood/deleteGood",
						data : dataStr,
						success : function() {
							alert("删除成功");
							$('img[src="../../img/shopaccount-icon.png"]')
									.closest($('div')).closest($('div')).next(
											'div').remove();
							$('img[src="../../img/shopaccount-icon.png"]')
									.closest($('div')).closest($('div'))
									.remove();

						}
					})
				});
		//下架
		$('li[class="shop-footlist-fou"]').click(function() {
			var dataStr = getShopId();
				$.ajax({
				type : "post",
				url : "/qiaomengapp/shopGood/changeStatusTo2",
				data : dataStr,
				success : function(){
					alert("下架成功");
					$('img[src="../../img/shopaccount-icon.png"]')
					.closest($('div')).closest($('div')).next(
							'div').remove();
					$('img[src="../../img/shopaccount-icon.png"]')
					.closest($('div')).closest($('div'))
					.remove();
					}
				});
		})
		
		//显示未销售的商品
		function getStatus2(){
			var $option=$(event.target);
			if($option.val()==1){
				manageGood();
			}else{
			$
			.ajax({
				type : "post",
				url : "/qiaomengapp/shopGood/manageGood1",
				dataType : "json",
				success : function(data) {
					for (var i = 0; i <= data.length; i++) {
						$(eval("d" + (i + 1)))
								.html(
										"<img src='../../img/shopaccount-icon2.png' onclick='checkedGood()'  shopGoodId='"
												+ data[i].id
												+ "'/>"
												+ "<div class='shopaccount-list left'>"
												+ "<img src='"+data[i].goodImgurl+"' />"
												+ "<ul class='shopaccount-listes left'>"
												+ "<li class='shopaccount-one'>"
												+ data[i].goodDesc
												+ "</li>"
												+ "<li class='shopaccount-two'>"
												+ "￥"
												+ data[i].price
												+ "&nbsp;<span>佣金:</span><span>￥"
												+ data[i].commission
												+ "</span></li>"
												+ "<li class='shopaccount-thr'>剩余<span>"
												+ data[i].sum
												+ "</span>"
												+ "<span style='margin-right: 0.05rem;'>件</span> 销量"
												+ "<span style='margin-right: 0.1rem;'>"
												+ data[i].salesCount
												+ "</span> 收藏<span>"
												+ data[i].focusNum
												+ "</span></li>"
												+ "</ul></div>")
					}
				}
			});}
		}
		function selectGoodByOrder(){
			var $option=$(event.target);
			if($option.val()==1){
				manageGood();
			}else if($option.val()==2){
				$
				.ajax({
					type : "post",
					url : "/qiaomengapp/shopGood/select_ShopGoodBySaleCount",
					dataType : "json",
					success : function(data) {
						for (var i = 0; i <= data.length; i++) {
							$(eval("d" + (i + 1)))
									.html(
											"<img src='../../img/shopaccount-icon2.png' onclick='checkedGood()'  shopGoodId='"
													+ data[i].id
													+ "'/>"
													+ "<div class='shopaccount-list left'>"
													+ "<img src='"+data[i].goodImgurl+"' />"
													+ "<ul class='shopaccount-listes left'>"
													+ "<li class='shopaccount-one'>"
													+ data[i].goodDesc
													+ "</li>"
													+ "<li class='shopaccount-two'>"
													+ "￥"
													+ data[i].price
													+ "&nbsp;<span>佣金:</span><span>￥"
													+ data[i].commission
													+ "</span></li>"
													+ "<li class='shopaccount-thr'>剩余<span>"
													+ data[i].sum
													+ "</span>"
													+ "<span style='margin-right: 0.05rem;'>件</span> 销量"
													+ "<span style='margin-right: 0.1rem;'>"
													+ data[i].salesCount
													+ "</span> 收藏<span>"
													+ data[i].focusNum
													+ "</span></li>"
													+ "</ul></div>")
						}
					}
				});
			}else if($option.val()==3){
				$
				.ajax({
					type : "post",
					url : "/qiaomengapp/shopGood/select_ShopGoodByCommission",
					dataType : "json",
					success : function(data) {
						for (var i = 0; i <= data.length; i++) {
							$(eval("d" + (i + 1)))
									.html(
											"<img src='../../img/shopaccount-icon2.png' onclick='checkedGood()'  shopGoodId='"
													+ data[i].id
													+ "'/>"
													+ "<div class='shopaccount-list left'>"
													+ "<img src='"+data[i].goodImgurl+"' />"
													+ "<ul class='shopaccount-listes left'>"
													+ "<li class='shopaccount-one'>"
													+ data[i].goodDesc
													+ "</li>"
													+ "<li class='shopaccount-two'>"
													+ "￥"
													+ data[i].price
													+ "&nbsp;<span>佣金:</span><span>￥"
													+ data[i].commission
													+ "</span></li>"
													+ "<li class='shopaccount-thr'>剩余<span>"
													+ data[i].sum
													+ "</span>"
													+ "<span style='margin-right: 0.05rem;'>件</span> 销量"
													+ "<span style='margin-right: 0.1rem;'>"
													+ data[i].salesCount
													+ "</span> 收藏<span>"
													+ data[i].focusNum
													+ "</span></li>"
													+ "</ul></div>")
						}
					}
				});
			}else if($option.val()==4){
				$
				.ajax({
					type : "post",
					url : "/qiaomengapp/shopGood/select_ShopGoodByPrice",
					dataType : "json",
					success : function(data) {
						for (var i = 0; i <= data.length; i++) {
							$(eval("d" + (i + 1)))
									.html(
											"<img src='../../img/shopaccount-icon2.png' onclick='checkedGood()'  shopGoodId='"
													+ data[i].id
													+ "'/>"
													+ "<div class='shopaccount-list left'>"
													+ "<img src='"+data[i].goodImgurl+"' />"
													+ "<ul class='shopaccount-listes left'>"
													+ "<li class='shopaccount-one'>"
													+ data[i].goodDesc
													+ "</li>"
													+ "<li class='shopaccount-two'>"
													+ "￥"
													+ data[i].price
													+ "&nbsp;<span>佣金:</span><span>￥"
													+ data[i].commission
													+ "</span></li>"
													+ "<li class='shopaccount-thr'>剩余<span>"
													+ data[i].sum
													+ "</span>"
													+ "<span style='margin-right: 0.05rem;'>件</span> 销量"
													+ "<span style='margin-right: 0.1rem;'>"
													+ data[i].salesCount
													+ "</span> 收藏<span>"
													+ data[i].focusNum
													+ "</span></li>"
													+ "</ul></div>")
						}
					}
				});
			}else{
				$
				.ajax({
					type : "post",
					url : "/qiaomengapp/shopGood/select_ShopGoodByfocus_num",
					dataType : "json",
					success : function(data) {
						for (var i = 0; i <= data.length; i++) {
							$(eval("d" + (i + 1)))
									.html(
											"<img src='../../img/shopaccount-icon2.png' onclick='checkedGood()'  shopGoodId='"
													+ data[i].id
													+ "'/>"
													+ "<div class='shopaccount-list left'>"
													+ "<img src='"+data[i].goodImgurl+"' />"
													+ "<ul class='shopaccount-listes left'>"
													+ "<li class='shopaccount-one'>"
													+ data[i].goodDesc
													+ "</li>"
													+ "<li class='shopaccount-two'>"
													+ "￥"
													+ data[i].price
													+ "&nbsp;<span>佣金:</span><span>￥"
													+ data[i].commission
													+ "</span></li>"
													+ "<li class='shopaccount-thr'>剩余<span>"
													+ data[i].sum
													+ "</span>"
													+ "<span style='margin-right: 0.05rem;'>件</span> 销量"
													+ "<span style='margin-right: 0.1rem;'>"
													+ data[i].salesCount
													+ "</span> 收藏<span>"
													+ data[i].focusNum
													+ "</span></li>"
													+ "</ul></div>")
						}
					}
				});
			}
		}
	</script>
</body>
</html>